import VJsonContext from "../../runtime/VJsonContext";
import eventBus from "../../studio/event-bus";
import {getRuntimeCmp} from "../../runtime/CmpStore";

/**
 * 公共混入方法
 */
export default {
    props: {
        vjson: Object as any,
        vcxt: VJsonContext
    },
    data() {
        return {
            _destroyed: true
        }
    },
    created() {
        this._destroyed = false
    },
    mounted() {
    },
    destroyed() {
        this._destroyed = true
    },
    computed: {
        calcLayoutClass() {
            return [
                'yv-layout-rt',
                this.vjson.isFlex ? 'yv-layout-flex' : '',
            ]
        },
        calcLayoutStyle() {
            const style: any = {}
            // 高度只在预览模式下生效
            if (this.vjson.height) {
                style.height = this.vjson.height
            }
            return style
        }
    },
    methods: {
        getRuntimeCmp,
        _scrollMe() {
            eventBus.$emit('bem-refresh', {sender: this, source: 'scroll'})
        },
    },

}